package com.zzyl.nursing.controller;

import com.zzyl.common.annotation.Log;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.core.page.TableDataInfo;
import com.zzyl.common.enums.BusinessType;
import com.zzyl.common.utils.poi.ExcelUtil;
import com.zzyl.nursing.domain.pojo.DeviceData;
import com.zzyl.nursing.service.IDeviceDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * deviceDateController
 * 
 * @author alexis
 * @date 2025-05-30
 */
@Api(tags = "deviceDate管理")
@RestController
@RequestMapping("/nursing/data")
public class DeviceDataController extends BaseController
{
    @Autowired
    private IDeviceDataService deviceDataService;

    /**
     * 查询deviceDate列表
     */
    @ApiOperation("查询deviceDate列表")
    @PreAuthorize("@ss.hasPermi('nursing:DeviceDate:list')")
    @GetMapping("/list")
    public TableDataInfo<List<DeviceData>> list(@ApiParam("deviceDate查询条件") DeviceData deviceData)
    {
        startPage();
        List<DeviceData> list = deviceDataService.selectDeviceDataList(deviceData);
        return getDataTable(list);
    }

    /**
     * 导出deviceDate列表
     */
    @ApiOperation("导出deviceDate列表")
    @PreAuthorize("@ss.hasPermi('nursing:DeviceDate:export')")
    @Log(title = "deviceDate", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(@ApiParam(value = "deviceDate查询条件") HttpServletResponse response, DeviceData deviceData)
    {
        List<DeviceData> list = deviceDataService.selectDeviceDataList(deviceData);
        ExcelUtil<DeviceData> util = new ExcelUtil<DeviceData>(DeviceData.class);
        util.exportExcel(response, list, "deviceDate数据");
    }

    /**
     * 获取deviceDate详细信息
     */
    @ApiOperation("获取deviceDate详细信息")
    @PreAuthorize("@ss.hasPermi('nursing:DeviceDate:query')")
    @GetMapping(value = "/{id}")
    public R<DeviceData> getInfo(@ApiParam("deviceDateID") @PathVariable("id") Long id)
    {
        return R.ok(deviceDataService.selectDeviceDataById(id));
    }

    /**
     * 新增deviceDate
     */
    @ApiOperation("新增deviceDate")
    @PreAuthorize("@ss.hasPermi('nursing:DeviceDate:add')")
    @Log(title = "deviceDate", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@ApiParam("deviceDate信息") @RequestBody DeviceData deviceData)
    {
        return toAjax(deviceDataService.insertDeviceData(deviceData));
    }

    /**
     * 修改deviceDate
     */
    @ApiOperation("修改deviceDate")
    @PreAuthorize("@ss.hasPermi('nursing:DeviceDate:edit')")
    @Log(title = "deviceDate", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@ApiParam("deviceDate信息") @RequestBody DeviceData deviceData)
    {
        return toAjax(deviceDataService.updateDeviceData(deviceData));
    }

    /**
     * 删除deviceDate
     */
    @ApiOperation("删除deviceDate")
    @PreAuthorize("@ss.hasPermi('nursing:DeviceDate:remove')")
    @Log(title = "deviceDate", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@ApiParam("deviceDateID数组") @PathVariable Long[] ids)
    {
        return toAjax(deviceDataService.deleteDeviceDataByIds(ids));
    }
}
